package com.sunda.spmsoversea.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.sunda.spmsoversea.entity.OverseaDnDtl;
import com.sunda.spmsoversea.mapper.OverseaDnDtlMapper;
import com.sunda.spmsoversea.service.IOverseaDnDtlService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 交货单明细采购订单明细关系表 服务实现类
 * </p>
 *
 * @author Wayne
 * @since 2021-12-14
 */
@Service
public class OverseaDnDtlServiceImpl extends ServiceImpl<OverseaDnDtlMapper, OverseaDnDtl> implements IOverseaDnDtlService {

    @Override
    public OverseaDnDtl getDnDtl(String sapDeliveryNote, String sapDeliveryNoteItem) {
        if (StringUtils.isEmpty(sapDeliveryNote) || StringUtils.isEmpty(sapDeliveryNoteItem)){
            return null;
        }
        return this.baseMapper.selectOne(new QueryWrapper<OverseaDnDtl>().eq("SAP_DELIVERY_NOTE", sapDeliveryNote)
                .eq("SAP_DELIVERY_NOTE_ITEM", sapDeliveryNoteItem));
    }

    /** 根据交货单号获取交货单明细信息 */
    @Override
    public List<Map<String, Object>> getDnDtlList(String sapDeliveryNote) {
        return this.baseMapper.getDnDtlList(sapDeliveryNote);
    }

    @Override
    public List<OverseaDnDtl> getDnDtls(String sapDeliveryNote) {
        return this.baseMapper.selectList(new QueryWrapper<OverseaDnDtl>().eq("SAP_DELIVERY_NOTE", sapDeliveryNote));
    }
}
